package com.example.demo.Controller;

import jakarta.servlet.http.HttpSession;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {
    @PostMapping("/login")
    public Boolean login(@RequestParam String name,@RequestParam String password, HttpSession session) {
        System.out.println(name);
        System.out.println(password);
        if(!StringUtils.hasLength(name) || !StringUtils.hasLength(password)) {
            return false;
        }
        if(name.equals("ml") && password.equals("ml")) {
            session.setAttribute("userName",name);
            System.out.println(true);
            return true;
        }
        return false;
    }
}
